<?php
include("backManager/Comment.php");
if(isset($_POST['submited'])){
		$comt=new Comment();
		BeanUtil::fetch($_POST, $comt);
		$isSucc=Comment::addComment($comt);
		if($isSucc)
		     header("location:index.php?targetPhp=comment/comList.php&showMsg=添加评论成功！");
}
  $docs=Comment::getDocs();
?>
<script>
    function addFail(){
    	$(".fail").html("新增失败！！");
    }
    var editor;
	KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
					resizeType : 1,
					allowPreviewEmoticons : false,
					allowImageUpload : false,
					items : [
						'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist', '|', 'emoticons', 'image', 'link']
				});
			});
</script>


<div class="rightTop"><span>添加新的评论</span></div><!--rightTop end-->
        <div class="thebody"><!--thebody start-->
        	<div class="bodyInside"><!--bodyInside start-->
    <form action="" method="POST">
                评论者ID：<span><?php echo $_SESSION['userid']; ?></span><input type="hidden" name="userid" value="<?php echo $_SESSION['userid']; ?>" /><br />
                评论内容：
                <textarea name="content" style="width:700px;height:200px;visibility:hidden;"></textarea><br />
                评论文章:
       <select name="docid">
       	  <?php
      	     foreach($docs as $keys=>$doc){ 
		        echo "<option value ='".$doc->id."'>".$doc->title."</option>";
			 }
		  ?>
       </select>
       <br/><br/><br/>
       <input type="submit" name="submited" value="添加确认" border="0" style=" width:70px; height:25px; background:#555555; border:0; color:#ffffff;" />
                </form>
       </div><!--bodyInside end-->
       <div class="rightTop"><span class="fail"></span></div>
</div><!--thebody end-->
<?php
     if(isset($_POST['submited'])){	
		if(!$isSucc)
			 echo "<script>addFail();</script>";
     }
?>